package org.scaffold;

import org.apache.commons.lang3.StringUtils;
import org.scaffold.utils.LogUtils;
import org.scaffold.velocity.CmdlineParserFactory;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.SQLException;

/**
 * 启动
 */
public class GenerateMain {

    public static void main(String[] args) throws IOException, InstantiationException, IllegalAccessException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //
        CmdlineParserFactory.build();
        CmdlineParserFactory.usage();
        System.setProperty("aaaaaaaaaa","dddddddddddd");
        while (true) {
//            LogUtils.info("请输入,退出exit.....");
            String path = new File("").getAbsolutePath();
            System.out.print(path + ">:");
            //输入命令
            String cmd = StringUtils.trimToNull(reader.readLine());
            if (cmd != null) {
                String EXIT = "exit";
                if (EXIT.equalsIgnoreCase(cmd.trim())) {
                    System.exit(0);
                }
                try {
                    CmdlineParserFactory.parse(cmd);
                    LogUtils.info("*********************ok*********************");
                } catch (IllegalArgumentException | SQLException | IOException d) {
                    LogUtils.info("error:%s,请检查输入", cmd);
                } catch (Exception e) {
                    LogUtils.info("error:" + e.getMessage());
                }
            }
        }
    }
}
